<?php

namespace App\Remote\AMap\Track;

use GuzzleHttp\Exception\GuzzleException;
use Illuminate\Validation\ValidationException;
use Symfony\Component\HttpFoundation\Request as RequestAlias;

class TerminalRemote extends Remote
{
    /**
     * @param int $sid
     * @param string $name
     * @param string $desc
     * @return mixed
     * @throws GuzzleException
     * @throws ValidationException
     */
    public static function add(int $sid, string $name, string $desc)
    {
        return self::customRequestV3(
            "/v1/track/terminal/add?" . http_build_query(self::withCommonHttpQueryParams()),
            RequestAlias::METHOD_POST,
            [
                "sid"  => $sid,
                "name" => $name,
                "desc" => $desc
            ],
            [
                'Content-Type' => 'application/x-www-form-urlencoded'
            ]
        );
    }

    /**
     * @param int $sid
     * @param string $name
     * @return mixed
     * @throws GuzzleException
     * @throws ValidationException
     */
    public static function list(int $sid, string $name)
    {
        return self::customRequestV3(
            "/v1/track/terminal/list?" . http_build_query(self::withCommonHttpQueryParams(
                [
                    "sid"  => $sid,
                    "name" => $name
                ]
            )),
            RequestAlias::METHOD_GET
        );
    }
}
